#import "BWCrossStitchSet.h"
#import "BWGridGeometry.h"
#import "BWCrossStitchChangeList.h"

#import "BWThread.h"

@implementation BWCrossStitchSet

- (id) initWithGeometry: (BWGridGeometry *) geoMetro
{
    if (self = [super init]) {
        geometry = [geoMetro retain];
    }

    return (self);

} // initWithGeometry


- (void) dealloc
{
    [geometry release];

    [super dealloc];

} // dealloc


- (BOOL) getSymbol: (BWCrossStitch * *) foundSymbol
           atPoint: (NSPoint) point
{
    BOOL foundOne = NO;
    int row, column;

    [geometry getRow: &row
              andColumn: &column
              atPoint: point];

    foundOne = [self getSymbol: foundSymbol
                     atRow: row
                     column: column];

    return (foundOne);

} // getSymbolAtPoint



- (void) applyChangeList: (BWCrossStitchChangeList *) changeList
{
    NSEnumerator *enumerator = [changeList changeEnumerator];
    BWCrossStitch *change;

    while (change = [enumerator nextObject]) {
        if ([change tag] == kCrossStitchChange_add) {

            [self addStitch: change];

        } else if ([change tag] == kCrossStitchChange_remove) {
            [self removeSymbolAtRow: [change row]
                  column: [change column]];
        }
    }
    
} // applyChangeList


@end // BWCrossStitchSet

